package com.microsec.iot.servlet;

import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

@ServerEndpoint("/getServer")
public class SocketServer{
	
	@OnOpen
	public void onOpen(Session session) {
		System.out.println(session);
		WebSession.getInstance().setSession(session);
	}	
	/**
	 * 收到客户端消息时触发
	 * @param relationId
	 * @param userCode
	 * @param message
	 * @return
	*/
	@OnMessage
	public void onMessage(Session session,String message) {
	}
 
	/**
	 * 异常时触发
	 * @param relationId
	 * @param userCode
	 * @param session
	*/
	@OnError
	 public void onError(Throwable throwable,Session session) {
	     System.out.print("onError"+throwable.toString());
	}
 
	/**
	 * 关闭连接时触发
	 * @param relationId
	 * @param userCode
	 * @param session
	*/
	@OnClose
	 public void onClose(Session session) {
		 System.out.print("onClose ");
	}		
}
